//
//  ToolBarView.m
//  QQChatDemo
//
//  Created by zkingsoft on 16/1/11.
//  Copyright (c) 2016年 zkingsoft. All rights reserved.
//

#import "ToolBarView.h"

@implementation ToolBarView


// 初始化工具条
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        // 背景
        _backGroundView = [[UIImageView alloc] init];
        _backGroundView.image = [UIImage imageNamed:@"chat_bottom_bg@2x.png"];
        _backGroundView.userInteractionEnabled = YES;
        [self addSubview:_backGroundView];
        
        
        
        // sendSoundButton
        _sendSoundButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_sendSoundButton setImage:[UIImage imageNamed:@"chat_bottom_voice_nor@2x.png"] forState:UIControlStateNormal];
        [self.backGroundView addSubview:_sendSoundButton];
        
        
        // addmoreButton
        _addMoreButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_addMoreButton setImage:[UIImage imageNamed:@"chat_bottom_up_nor@2x.png"] forState:UIControlStateNormal];
        [self.backGroundView addSubview:_addMoreButton];
        
        
        
        // expressButton
        _expressButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_expressButton setImage:[UIImage imageNamed:@"chat_bottom_smile_nor@2x.png"] forState:UIControlStateNormal];
        [self.backGroundView addSubview:_expressButton];
        
        
        
        // textField
        _inputTextField = [[UITextField alloc] init];
        _inputTextField.returnKeyType = UIReturnKeySend;
        _inputTextField.enablesReturnKeyAutomatically = YES;
        _inputTextField.background = [UIImage imageNamed:@"chat_bottom_textfield"];
        [self.backGroundView addSubview:_inputTextField];

    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    _backGroundView.sd_layout
    .leftSpaceToView(self, 0)
    .bottomSpaceToView(self, 0)
    .widthIs(K_WIDTH)
    .heightIs(44);
    
    _sendSoundButton.sd_layout
    .leftSpaceToView(_backGroundView, 0)
    .topSpaceToView(_backGroundView, 0)
    .widthIs(44)
    .heightIs(44);
    
    _addMoreButton.sd_layout
    .rightSpaceToView(_backGroundView, 0)
    .topSpaceToView(_backGroundView, 0)
    .widthIs(44)
    .heightIs(44);
    
    _expressButton.sd_layout
    .rightSpaceToView(_backGroundView, 44)
    .topSpaceToView(_backGroundView, 0)
    .widthIs(44)
    .heightIs(44);

    _inputTextField.sd_layout
    .leftSpaceToView(_backGroundView, 44)
    .rightSpaceToView(_backGroundView, 44*2)
    .heightIs(40)
    .topSpaceToView(_backGroundView, 2);
    
    _inputTextField.leftView = [[UIView alloc] init];
    _inputTextField.leftView.sd_layout
    .leftSpaceToView(self.inputTextField, 0)
    .topSpaceToView(self.inputTextField, 0)
    .widthIs(8)
    .heightIs(1);
    _inputTextField.leftViewMode = UITextFieldViewModeAlways;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
